#include <iostream>
#include <vector>
using namespace std;
int solution(vector<int>& nums, int value) {
    int windowSum = 0;
    int left = 0;
    int ans = 0;
    int n = nums.size();

    for (int right = 0; right < n; right++) {
        windowSum += nums[right];
        if (windowSum <= value) {
            ans = max(ans, right - left + 1);
        }
        while (windowSum > value) {
            windowSum -= nums[left];
            left++;
        }
    }
    return ans;
}
int main() {
    int n;
    cin >> n;
    vector<int> nums(n);

    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }

    int maxSum;
    cin >> maxSum;

    cout << solution(nums, maxSum) << endl;

    return 0;
}
